#! /bin/php
<?php
/**
 * Base_App
 *
 * LICENSE
 *
 * This source file is subject to the new CC-GNU LGPL
 * It is available through the world-wide-web at this URL:
 * http://creativecommons.org/licenses/LGPL/2.1/
 *
 * @category   Base_App
 * @copyright  Copyright (c) 2009 Alexander fanatique* Thomas (me@alexander-thomas.net)
 * @license    http://creativecommons.org/licenses/LGPL/2.1/
 */

ini_set('memory_limit', '8M');

/** Determine the environment and the include paths*/

$dirname = dirname(__FILE__) . '/';

$path_include = $dirname . '../../library/';
$path_application = $dirname . '../';
$path_controllers = $dirname . '../controllers/'; // This one's unused

set_include_path(get_include_path() . PATH_SEPARATOR . $path_include . PATH_SEPARATOR . $path_application);
require_once 'Zend/Loader/Autoloader/Resource.php';
require_once 'Zend/Loader/Autoloader.php';

$resourceLoader = new Zend_Loader_Autoloader_Resource(array(
    'basePath'  => $path_application.'../',
    'namespace' => '',
));
$resourceLoader	->addResourceType('base', 'library/Base/', 'Base')
               	->addResourceType('service', 'application/Service/', 'Service')
               	->addResourceType('Model', 'application/Model/', 'Model')
               	->addResourceType('Migration', 'application/Migrations/', 'Migrations')
               	->addResourceType('exception', 'application/Exception/', 'Exception')
				->addResourceType('zend', 'library/Zend/', 'Zend');

$init = Base_App_Initialization::getInstance();
$init->registerApplicationPath($path_application);
$environment = $init->getEnvironment();
$appConfig = $init->setupApplicationConfig($environment);
#$init->setupLogger();
$init->setupDb();
$db = Zend_Registry::get('db');
$migrations = new Migrations_Migrations($db, $appConfig->db->dbname);
#die($migrations->getSql());
$migrations->run();
